#pragma once

#ifdef __QT5_TARGET

#include <QtCore/QList>
#include <QtCore/QString>

#else

#include <QList>
#include <QString>

#endif

#include "korlapadmin_model_global.h"
class KORLAPADMIN_MODEL_EXPORT Utils
{
public:
	Utils(void){}
	~Utils(void){}
	static QList<QString> uintToString(QList<unsigned int> list)
	{
		QList<QString> lst;
		for(int i = 0; i < list.count();++i)
		{
			lst << QString::number(list.at(i));
		}
		return lst;
	}

	template<typename T,typename compare_less>
	static int binary_search(QList<T>* list, T target) {
		int low = 0;
		int high = list->count()-1;
		while (low <= high) {
			int middle = low + (high - low)/2;
			if (compare_less(*target, list[middle]))
				high = middle - 1;
			else if (compare_less(*list[middle],*target))
				low = middle + 1;
			else
				return middle;
		}
		return low;
}
	static bool lessDate(QDateTime* first, QDateTime* second)
	{
		QString f = first->toString();
		QString s = second->toString();
		bool b = *first < *second;
		return b;
	}
};



